{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header"></div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
                   data-auth-add="{:$auth->check('goods_order/add')}"
                   data-auth-edit="{:$auth->check('goods_order/edit')}"
                   data-auth-delete="{:$auth->check('goods_order/del')}"
                   data-auth-recyclebin="{:$auth->check('goods_order/recyclebin')}"
            ></table>
        </div>
    </div>
</div>
<script type="text/html" id="barTool">
    <a data-open='{:url("/admin/goods_order/info")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs {:$auth->check('special/edit')?'':'layui-hide'}" title="查看详情">查看详情</a>
    {{#  if(d.status == 1){ }}

    <a data-open='{:url("edit")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs {:$auth->check('special/edit')?'':'layui-hide'}" title="去发货">去发货</a>
    {{#  } }}
    <a href='{:url("del")}?id={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('item/del')?'':'layui-hide'}"><i
            class='iconfont icon-trash_fill'></i></a>
</script>
{/block}

{block name="script"}
<script type="text/javascript">
    layui.use('yznTable', function () {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: '{:url("add")}',
            edit_url: '{:url("edit")}',
            delete_url: '{:url("del")}',
            modify_url: "{:url('multi')}",
            recyclebin_url: "{:url('recyclebin')}",
        };

        table.render({
            init: init,
            toolbar: ['refresh', 'add', 'delete'],
            url: '{:url("index")}',
            cols: [
                [
                    {type: 'checkbox', fixed: 'left'},
                    {field: 'member_id', title: '用户ID', minWidth: 80},
                    {field: 'out_trade_no', align: "center", title: '订单编号', minWidth: 160, searchOp: 'LIKE'},
                    {field: 'member.nickname', title: '昵称', minWidth: 80, searchOp: 'LIKE', minWidth: 110},

                    {field: 'goods_name', align: "center", title: '商品名称', minWidth: 160, searchOp: 'LIKE'},
                    {
                        field: 'goods_image',
                        title: '图片',
                        align: "center",
                        minWidth: 80,
                        search: false,
                        templet: yznTable.formatter.image
                    },

                    {
                        field: 'goods_price',
                        align: "center",
                        title: '商品价格',
                        minWidth: 120,
                        search: false,
                        searchTip: '商品价格'
                    },
                    {
                        field: 'amount',
                        align: "center",
                        title: '总金额',
                        minWidth: 120,
                        search: false,
                        searchTip: '总金额'
                    },
                    {
                        field: 'pay_amount',
                        align: "center",
                        title: '支付金额',
                        minWidth: 120,
                        search: false,
                        searchTip: '支付金额'
                    },
                    {
                        field: 'pay_type',
                        align: 'center',
                        title: '支付方式',
                        minWidth: 100,
                        search: false,
                        searchTip: '支付方式',
                        templet: yznTable.formatter.label,
                        selectList: {0: '钱包', 1: '微信'}
                    },
                    {field: 'notes', title: '备注', search: false, minWidth: 110},
                    {
                        field: 'status',
                        align: 'center',
                        width: 120,
                        title: '状态',
                        templet: yznTable.formatter.status,
                        selectList: {
                            0: '待支付',
                            1: '待发货',
                            2: '已发货',
                            3: '交易完成',
                            4: '取消订单',
                        },
                    },
                    {field: 'phone', align: "center", title: '手机号', minWidth: 120, searchOp: 'LIKE'},
                    {field: 'realname', align: "center", title: '真实姓名', searchOp: 'LIKE', minWidth: 110},
                    {
                        field: 'create_time',
                        title: '创建时间',
                        minWidth: 80,
                        width: 180,
                        search: false,
                        templet: yznTable.formatter.datetime
                    },
                    {
                        field: 'pay_time',
                        title: '支付时间',
                        minWidth: 80,
                        width: 180,
                        search: 'range',
                        templet: yznTable.formatter.datetime
                    },
                    {fixed: 'right', align: 'center', width: 180, title: '操作', toolbar: '#barTool'}

                ]
            ],
            page: {}
        });

        yznTable.bindevent();
    });
</script>
{/block}